<template>
    <div class="shop advertisingManagement">
        <div style="display: flex;justify-content: space-between">

            <el-form :inline="true"
                     size="mini"
                     class="form">
                <el-form-item>
                    <el-button class="addBtn" type="primary" @click="isShowDetails()">新增</el-button>
                </el-form-item>
            </el-form>

            <el-form :inline="true"
                     size="mini"
                     :model="form"
                     class="form">
                <el-form-item label="广告位:">
                    <template>
                        <el-select v-model="form.adboard"
                                   clearable
                                   placeholder="请选择">
                            <el-option
                                    v-for="item in boardlist"
                                    :value="item.id"
                                    :key="item.id"
                                    :label="item.name">
                            </el-option>
                        </el-select>
                    </template>
                </el-form-item>
                <el-form-item label='有效时间:'>
                    <el-date-picker v-model="form.start_time"
                                    type="date"
                                    style="width:136px"
                                    value-format="yyyy-MM-dd"
                                    placeholder="选择开始时间">
                    </el-date-picker>
                    ~
                    <el-date-picker v-model="form.end_time"
                                    type="date"
                                    style="width:136px"
                                    value-format="yyyy-MM-dd"
                                    placeholder="选择结束时间"></el-date-picker>
                </el-form-item>
                <el-form-item label="关键词:">
                    <el-input class="input"
                              v-model="form.title" placeholder="输入广告名称名称" clearable></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="searchShopMin">搜索</el-button>
                </el-form-item>

            </el-form>
        </div>
        <el-table
                :data="tableData"
                style="width:100%"
                max-height="600"
                class="shop_table_list"
                :cell-style="tc"
                :header-cell-style="tccolor"
        >
            <el-table-column prop="id" label="ID"></el-table-column>
            <el-table-column label="广告名称">
                <template slot-scope="scope">
                    <p class="shop_title">{{scope.row.title}}</p>
                </template>
            </el-table-column>

            <el-table-column label="图片" width="160">
                <template slot-scope="scope">
                    <div>
                        <img
                                :key="scope.row.id"
                                style="width:100px;"
                                :src="scope.row.content ? scope.row.content : errorImg"
                                alt
                        />
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="adboard" label="所属广告位模块"></el-table-column>
            <el-table-column prop="url_type_name" label="链接类型"></el-table-column>
            <el-table-column prop="url_param" label="链接地址"></el-table-column>
            <el-table-column label="有效时间" width="270">
                <template slot-scope="scope">
                    <p>{{scope.row.start_time}}-{{scope.row.end_time}}</p>
                </template>
            </el-table-column>
            <el-table-column label='展示排序'
                             width="100px">
                <template slot-scope="scope">
                    <el-input v-model="scope.row.ordid"
                              type="number"
                              @blur="labelOrderSortChange(scope.row.id, scope.row.ordid)"/>
                </template>
            </el-table-column>
            <el-table-column label="状态" width="110">
                <template slot-scope="scope">
                    <el-switch
                            :key="scope.row.id"
                            :active-value="1"
                            :inactive-value="0"
                            :value="scope.row.status"
                            @change="isUseActivityChange(scope.row.id,scope.row.status)"
                    ></el-switch>
                    <p class="status—desc" v-if="scope.row.status==1">已启用</p>
                    <p class="status—desc" v-if="scope.row.status==2">已删除</p>
                    <p class="status—desc" v-if="scope.row.status==0">已下架</p>
                </template>
            </el-table-column>
            <el-table-column label="点击数（PV）今日/累计" width="120">
                <template slot-scope="scope">
                    <p>{{scope.row.hits_today}}/{{scope.row.hits}}</p>
                </template>
            </el-table-column>
            <el-table-column label="操作" fixed="right" width="160">
                <template slot-scope="scope">
                    <el-button size="mini" @click="openShopMinDetail(scope.row)">查看</el-button>
                    <el-button size="mini" type="danger" @click="deleteShopMin(scope.row.id)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>

        <el-col :span="24">
            <div class="pagination">
                <el-pagination
                        background
                        @current-change="pageChange"
                        :current-page="form.page"
                        :page-size="20"
                        layout="total, prev, pager, next, jumper"
                        :total="total"
                ></el-pagination>
            </div>
        </el-col>

        <jdialog
                title="添加广告"
                :visible.sync="isShowDetail"
                width="600px">
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>广告名称:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.name"></el-input>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>广告位:</el-col>
                <el-col :span="8">
                    <el-select v-model="addlist.board_id"
                               clearable
                               placeholder="请选择">
                        <el-option
                                v-for="item in boardlist"
                                :value="item.id"
                                :key="item.id"
                                :label="item.name">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <!--导航选中图片-->
            <el-row class="shop_info_dalog">
                <el-col :span="4">导航选中图片:</el-col>
                <el-col :span="20">
                    <uploadImg
                            flieName="shopadministration_pic_list"
                            :n="1"
                            :oldImgs="addlist.selected_content"
                            @getFile="getFile2"
                    ></uploadImg>
                    <p>仅用于支付宝小程序或微信小程序底部导航</p>
                    <!--<div class="img_main" v-show="content.length">主图</div>-->
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4">最高展示次数:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.most_show_count"></el-input>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4">排序:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.ordid"></el-input>
                </el-col>
            </el-row>

            <!--标题-->
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>标题:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.title"></el-input>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>副标题:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.sub_title"></el-input>
                </el-col>
            </el-row>
            <!--图片-->
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>广告图片:</el-col>
                <el-col :span="20">
                    <uploadImg
                            flieName="shopadministration_pic_list"
                            :n="1"
                            :oldImgs="addlist.img_url"
                            @getFile="getFile"
                    ></uploadImg>
                    <!--<div class="img_main" v-show="content.length">主图</div>-->
                </el-col>
            </el-row>
            <!--颜色-->
            <el-row class="shop_info_dalog">
                <el-col :span="4">背景颜色:</el-col>
                <el-col :span="20">
                    <el-input placeholder="示例rgb(228,57,60,0.5)" v-model="addlist.bg_color"></el-input>
                    <p>例：rgb(228,57,60,0.5)前三位为十六进制RGB值，最后一位是透明度，区间为0-1；仅限首页轮播广告有效</p>
                </el-col>

            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4">字体颜色:</el-col>
                <el-col :span="20">
                    <el-input placeholder="示例rgb(228,57,60,0.5)" v-model="addlist.font_color"></el-input>
                    <p> 例：rgb(228,57,60,0.5)前三位为十六进制RGB值；仅限首页轮播广告有效</p>
                </el-col>

            </el-row>
            <!--跳转类型-->
            <el-row class="shop_info_dalog">
                <el-col :span="4">跳转类型:</el-col>
                <el-col :span="20">
                    <el-select v-model="addlist.url_type"
                               clearable
                               placeholder="请选择">
                        <el-option
                                v-for="item in addlistboard"
                                :value="item.id"
                                :key="item.id"
                                :label="item.name">
                        </el-option>
                    </el-select>
                </el-col>

            </el-row>
            <el-row class="shop_info_dalog"
                    v-if="addlist.url_type=='1'||addlist.url_type=='2'">
                <el-col :span="4">跳转链接:</el-col>
                <el-col :span="20">
                    <el-input placeholder="带上http://的连接地址"
                              v-model="addlist.url_param"></el-input>
                    <p>只有广告类型为外部链接时输入</p>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog" v-if="addlist.url_type=='3'">
                <el-col :span="4">跳转商品id:</el-col>
                <el-col :span="20">
                    <el-input placeholder="num_iid"
                              v-model="addlist.url_param"></el-input>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog"
                    v-if="addlist.url_type==4">
                <el-col :span="4">应用内部页面:</el-col>
                <el-col :span="12">
                    <el-select v-model="boardPage"
                               :blur="boaPag(boardPage)"
                               clearable
                               placeholder="请选择">
                        <el-option
                                v-for="item in boardPages"
                                :value="item.value"
                                :key="item.id"
                                :label="item.type!=1?item.name+'(不支持小程序)':item.name">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog" v-if="isshowpage">
                <el-col :span="4">app页面参数:</el-col>
                <el-col :span="20">
                    <el-input placeholder="app页面参数"
                              v-model="addlist.url_param"></el-input>
                    <p>参数demo：{{desc}}</p>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog" v-if="isshowpageqt">
                <el-col :span="4">其他页面:</el-col>
                <el-col :span="20">
                    <el-input placeholder="其他页面"
                              v-model="addlist.url_param"></el-input>
                </el-col>
            </el-row>
            <!--时间-->
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>广告时间:</el-col>
                <el-col :span="20">
                    <el-date-picker v-model="addlist.start_time"
                                    type="date"
                                    style="width:146px"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    placeholder="选择开始时间">
                    </el-date-picker>
                    ~
                    <el-date-picker v-model="addlist.end_time"
                                    type="date"
                                    style="width:146px"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    placeholder="选择结束时间"></el-date-picker>
                </el-col>
            </el-row>
            <!--是否启用-->
            <el-row class="shop_info_dalog">
                <el-col :span="4">是否启用:</el-col>
                <el-col :span="8">
                    <el-radio-group v-model="addlist.status">
                        <el-radio :label="0">否</el-radio>
                        <el-radio :label="1">是</el-radio>
                    </el-radio-group>
                </el-col>
            </el-row>
            <div class="dialog-footer">
                <el-button size='mini' @click="isShowDetail = false">取 消</el-button>
                <el-button size='mini' type="primary" @click="submitGoodsInfo">确 定</el-button>
            </div>
        </jdialog>
        <jdialog
                title="修改广告"
                :visible.sync="isShowUpdate"
                width="600px">
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>广告名称:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.name"></el-input>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>广告位:</el-col>
                <el-col :span="8">
                    <el-select v-model="addlist.board_id"
                               clearable
                               placeholder="请选择">
                        <el-option
                                v-for="item in boardlist"
                                :value="item.id"
                                :key="item.id"
                                :label="item.name">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4">导航选中图片:</el-col>
                <el-col :span="20">
                    <uploadImg
                            flieName="shopadministration_pic_list"
                            :n="1"
                            :oldImgs="addlist.selected_content"
                            @getFile="getFile2"
                    ></uploadImg>
                    <p>仅用于支付宝小程序或微信小程序底部导航</p>
                    <!--<div class="img_main" v-show="content.length">主图</div>-->
                </el-col>
            </el-row>

            <el-row class="shop_info_dalog">
                <el-col :span="4">最高展示次数:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.most_show_count"></el-input>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4">排序:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.ordid"></el-input>
                </el-col>
            </el-row>

            <!--标题-->
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>标题:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.title"></el-input>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>副标题:</el-col>
                <el-col :span="8">
                    <el-input placeholder v-model="addlist.sub_title"></el-input>
                </el-col>
            </el-row>
            <!--图片-->
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>广告图片:</el-col>
                <el-col :span="20">
                    <uploadImg
                            flieName="shopadministration_pic_list"
                            :n="1"
                            :oldImgs="img_url"
                            @getFile="getFile"
                    ></uploadImg>
                    <!--<div class="img_main" v-show="content.length">主图</div>-->
                </el-col>
            </el-row>
            <!--颜色-->
            <el-row class="shop_info_dalog">
                <el-col :span="4">背景颜色:</el-col>
                <el-col :span="20">
                    <el-input placeholder="示例rgb(228,57,60,0.5)" v-model="addlist.bg_color"></el-input>
                    <p>例：rgb(228,57,60,0.5)前三位为十六进制RGB值，最后一位是透明度，区间为0-1；仅限首页轮播广告有效</p>
                </el-col>

            </el-row>
            <el-row class="shop_info_dalog">
                <el-col :span="4">字体颜色:</el-col>
                <el-col :span="20">
                    <el-input placeholder="示例rgb(228,57,60,0.5)" v-model="addlist.font_color"></el-input>
                    <p> 例：rgb(228,57,60,0.5)前三位为十六进制RGB值；仅限首页轮播广告有效</p>
                </el-col>

            </el-row>
            <!--跳转类型-->
            <el-row class="shop_info_dalog">
                <el-col :span="4">跳转类型:</el-col>
                <el-col :span="20">
                    <el-select v-model="addlist.url_type"
                               clearable
                               placeholder="请选择">
                        <el-option
                                v-for="item in addlistboard"
                                :value="item.id"
                                :key="item.id"
                                :label="item.name">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog"
                    v-if="addlist.url_type==1||addlist.url_type==2">
                <el-col :span="4">跳转链接:</el-col>
                <el-col :span="20">
                    <el-input placeholder="带上http://的连接地址"
                              v-model="addlist.url_param"></el-input>
                    <p>只有广告类型为外部链接时输入</p>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog" v-if="addlist.url_type==3">
                <el-col :span="4">跳转商品id:</el-col>
                <el-col :span="20">
                    <el-input placeholder="num_iid"
                              v-model="addlist.url_param"></el-input>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog"
                    v-if="addlist.url_type==4">
                <el-col :span="4">应用内部页面:</el-col>
                <el-col :span="12">
                    <el-select v-model="boardPage"
                               :blur="boaPag(boardPage)"
                               clearable
                               placeholder="请选择">
                        <el-option

                                v-for="item in boardPages"
                                :value="item.value"
                                :key="item.id"
                                :label="item.type!=1?item.name+'(不支持小程序)':item.name">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog" v-if="isshowpage">
                <el-col :span="4">app页面参数:</el-col>
                <el-col :span="20">
                    <el-input placeholder="app页面参数"
                              v-model="addlist.url_param"></el-input>
                    <p>参数demo：{{desc}}</p>
                </el-col>
            </el-row>
            <el-row class="shop_info_dalog" v-if="isshowpageqt">
                <el-col :span="4">其他页面:</el-col>
                <el-col :span="20">
                    <el-input placeholder="其他页面"
                              v-model="addlist.url_param"></el-input>
                </el-col>
            </el-row>
            <!--时间-->
            <el-row class="shop_info_dalog">
                <el-col :span="4"><span style="color: red">*</span>广告时间:</el-col>
                <el-col :span="20">
                    <el-date-picker v-model="addlist.start_time"
                                    type="date"
                                    style="width:146px"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    placeholder="选择开始时间">
                    </el-date-picker>
                    ~
                    <el-date-picker v-model="addlist.end_time"
                                    type="date"
                                    style="width:146px"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    placeholder="选择结束时间"></el-date-picker>
                </el-col>
            </el-row>
            <!--是否启用-->
            <el-row class="shop_info_dalog">
                <el-col :span="4">是否启用:</el-col>
                <el-col :span="8">
                    <el-radio-group v-model="addlist.status">
                        <el-radio :label="0">否</el-radio>
                        <el-radio :label="1">是</el-radio>
                    </el-radio-group>
                </el-col>
            </el-row>
            <div class="dialog-footer">
                <el-button size='mini' @click="isShowUpdate = false">取 消</el-button>
                <el-button size='mini' type="primary" @click="UpdateGoodsInfo">确 定</el-button>
            </div>
        </jdialog>

    </div>
</template>

<script>
    import errorImg from "@/assets/images/error_img.png";
    import uploadImg from "@/components/uploadImg";
    import {
        adlist,
        addelete,
        adupdatesort,
        adboardlistSimple,
        adupdatestatus,
        adcreate,
        adupdate
    } from "@/api/goods";

    // import shopadministrationdetail from './shopadministrationdetail'
    export default {
        name: "advertisingManagement",
        components: {
            uploadImg
        },
        mounted() {
            this.getProductListData();
        },
        data() {
            return {
                isshowpageqt: false,
                selected_content: [],
                isShowUpdate: false,
                desc: '',
                srp: ['couponList', 'specialPerformanceGoods', 'detail', '/goodsDetail', 'redPacketGoods'],
                descList: ['id=物料id&name=专区name(指定库列表)', 'id=专场id', 'numiid=淘宝商品id', 'id=红包兑换商品id', 'id=专场id'],
                isshowpage: false,
                pavul: '',
                boardPage: '',
                radio: 0,
                boardPages: [
                    {
                        name: '抵现卡',
                        value: 'creditCard',
                        id: 0
                    }, {
                        name: '今日值得购买',
                        value: 'todayBuy',
                        id: 1
                    }, {
                        name: '优惠券页(v1.0)',
                        value: 'couponList',
                        id: 2,
                        need_param: 1,
                        desc: 'id=物料id&name=专区name(指定库列表)'
                    },
                    {
                        name: '超级大牌',
                        value: 'superBrand',
                        id: 3
                    }, {
                        name: '热门优惠券商品分享',
                        value: 'hotGoodsShare',
                        id: 4
                    }, {
                        name: '成为合伙人',
                        id: 5,
                        value: 'partnerApply',

                    }, {
                        name: '每日分享',
                        id: 6,
                        value: 'recommendShare',
                    }, {
                        name: '任务中心',
                        id: 7,
                        value: 'taskCenter',

                    }, {
                        name: '签到',
                        id: 8,
                        value: 'daySignIn',

                    }, {
                        name: '战队',
                        id: 9,
                        value: 'team',

                    }, {
                        name: '好物专场',
                        id: 10,
                        value: 'specialPerformanceGoods',
                        need_param: 1,
                        desc: 'id=专场id'
                    }, {
                        name: '首页',
                        id: 11,
                        type: 1,
                        value: 'home',

                    }, {
                        name: '淘宝联盟商品分类',
                        id: 12,
                        value: 'classify',

                    }, {
                        name: '幕后街',
                        id: 13,
                        type: 1,
                        value: 'jingStore',

                    }, {
                        name: '我的',
                        id: 14,
                        type: 1,
                        value: 'mine',

                    }, {
                        name: '品牌圈',
                        id: 15,
                        value: 'brandHallList',

                    }, {
                        name: '淘礼金专区',
                        id: 16,
                        value: 'tljChannel',

                    }, {
                        name: '限时购专区',
                        id: 17,
                        value: 'tljTimeLimit',

                    }, {
                        name: '新手专区',
                        id: 18,
                        value: 'newPeopleList',

                    }, {
                        name: '幸运翻翻乐',
                        id: 19,
                        value: 'luckyDraw',

                    }, {
                        name: '兑换淘礼金',
                        id: 20,
                        value: 'exchangeTlj',

                    }, {
                        name: '淘宝预售集和页',
                        id: 21,
                        value: 'preSaleIndex?id=26257',

                    }, {
                        name: '淘宝联盟指定商品',
                        id: 22,
                        value: 'detail',
                        need_param: 1,
                        desc: 'numiid=淘宝商品id'
                    }, {
                        name: '红包兑换指定商品',
                        id: 23,
                        type: 1,
                        value: '/goodsDetail',
                        need_param: 1,
                        desc: 'id=红包兑换商品id'

                    }, {
                        name: '红包专场',
                        id: 24,
                        type: 1,
                        value: 'redPacketGoods',
                        need_param: 1,
                        desc: 'id=专场id'

                    }, {
                        name: 'Other',
                        id: 25,
                        type: 1,
                        value: 'other',

                    }
                ],
                addlistboard: [
                    {
                        name: '无',
                        id: 0,
                    }, {
                        name: '淘宝（外部链接）',
                        id: 1,
                    }, {
                        name: '非淘宝（外部链接）',
                        id: 2,
                    }, {
                        name: '内部商品库',
                        id: 3,
                    }, {
                        name: 'APP内部',
                        id: 4,
                    }],
                //展示详情
                isShowDetail: false,
                errorImg,
                form: {
                    end_time: '',
                    start_time: '',
                    title: "",
                    adboard: "",
                    page: 1
                },
                total: 0,
                tableData: [],
                //商品详情
                productDetail: {},
                //图片列表
                img_url: [],
                boardlist: [],
                addlist: {
                    most_show_count: 0,
                    board_id: '',
                    title: '',
                    sub_title: '',
                    content: [],
                    start_time: '',
                    end_time: '',
                    ordid: '',
                    status: 0,
                    url_type: '无',
                    url_param: '',
                    bg_color: '',
                    font_color: ''
                }
            };
        },
        methods: {
            isShowDetails() {
                this.isShowDetail = true;
                this.addlist = {
                    most_show_count: 0,
                    board_id: '',
                    title: '',
                    sub_title: '',
                    content: [],
                    start_time: '',
                    end_time: '',
                    ordid: '',
                    status: 0,
                    url_type: '无',
                    url_param: '',
                    bg_color: '',
                    font_color: ''
                }
                this.img_url = []

            },
            boaPag(e) {
                if (e == 'couponList' || e == 'specialPerformanceGoods'
                    || e == 'detail' || e == '/goodsDetail' || e == 'redPacketGoods') {
                    this.isshowpage = true;
                    this.isshowpageqt = false;
                    this.desc = this.descList[this.srp.indexOf(e)]
                } else if (e == 'other') {
                    this.isshowpage = false;
                    this.isshowpageqt = true;
                } else {
                    this.isshowpage = false;
                    this.isshowpageqt = false;
                }
            },
            //排序
            labelOrderSortChange(label_id, ordid) {
                adupdatesort({id: label_id, ordid: ordid}).then(res => {
                    this.$message.success(res.message)
                })
            },
            tc() {
                return "text-align:center; color:#333333; font-size:12px;";
            },
            tccolor() {
                return "text-align:center;background-color:#f5f5f5; font-size:14px;";
            },
            //获取商品列表
            async getProductListData() {
                var url =
                    "title=" + this.form.title +
                    "&adboard=" + this.form.adboard +
                    "&end_time=" + this.form.end_time +
                    "&start_time=" + this.form.start_time +
                    "&page=" + this.form.page;
                let res = await adlist(url);
                let a = await adboardlistSimple({})
                this.tableData = res.data.data;
                this.boardlist = a.data;
                this.total = res.data.total;
            },
            //根据关键词重新获取小店
            searchShopMin() {
                this.getProductListData();
            },
            pageChange(page) {
                this.form.page = page;
                this.getProductListData();
            },
            async isUseActivityChange(id, e) {
                if (e === 1) {
                    //下架
                    this.getDownProductData(id);
                } else {
                    //上架
                    this.getUpProductData(id);
                }
            },
            //上架商品
            async getUpProductData(id) {
                let res = await adupdatestatus({id, status: 1});
                if (res.code === 10000) {
                    this.$message.success("启用成功");
                    this.getProductListData();
                } else {
                    this.$message.error(res.message);
                }
            },
            //下架商品
            async getDownProductData(id) {
                let res = await adupdatestatus({id, status: 0});
                if (res.code === 10000) {
                    this.$message.success("下架成功");
                    this.getProductListData();
                } else {
                    this.$message.error(res.message);
                }
            },

            //删除商品
            async getDeleteProductData(cid) {
                let res = await addelete({id: cid});
                if (res.code === 10000) {
                    this.$message.success("删除成功");
                    this.getProductListData();
                } else {
                    this.$message.error(res.message);
                }
            },
            //查看详情
            openShopMinDetail(item) {
                if (item.url_param.indexOf('?')!=-1){
                    this.addlist = item;
                    this.boardPage = item.url_param.split("?")[0]
                    this.addlist.url_param = item.url_param.split("?")[1]

                }else{
                    this.boardPage = item.url_param
                    this.addlist = item;
                }
                this.img_url = []
                this.selected_content = []
                this.isShowUpdate = true;
                this.img_url.push(item.content)
                this.selected_content.push(item.selected_content)
            },

            //删除详情
            deleteShopMin(id) {
                this.$confirm('确认删除该商品', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消'
                }).then(() => {
                    this.getDeleteProductData(id);
                }).catch(() => {
                });

            },

            //获取商品图片
            getFile(file) {
                if (file.files && file.files.length && file.name == 'shopadministration_pic_list') {
                    this.img_url = file.files.map(obj => obj.url)
                }
            },
            //获取商品图片
            getFile2(file) {
                if (file.files && file.files.length && file.name == 'shopadministration_pic_list') {
                    this.selected_content = file.files.map(obj => obj.url)
                }
            },

            //修改商品点击确定
            UpdateGoodsInfo() {
                this.getEditUpdateData();
            },
            //添加商品点击确定
            submitGoodsInfo() {
                this.getEditProductData();
            },

            //添加广告
            async getEditProductData() {
                let a;
                let form;
                if (this.addlist.name == '' || this.addlist.name == undefined) {
                    this.$message.error('请输入广告名称');
                } else if (this.addlist.board_id == '' || this.addlist.board_id == undefined) {
                    this.$message.error('请选择广告位');
                } else if (this.addlist.title == '' || this.addlist.title == undefined) {
                    this.$message.error('请输入标题');
                } else if (this.addlist.sub_title == '' || this.addlist.sub_title == undefined) {
                    this.$message.error('请输入副标题');
                } else if (this.addlist.start_time == '' || this.addlist.start_time == undefined ||
                    this.addlist.end_time == '' || this.addlist.end_time == undefined) {
                    this.$message.error('请选择广告时间');
                } else if (this.img_url[0] == '' || this.img_url[0] == undefined) {
                    this.$message.error('请添加广告图片');
                } else if (this.addlist.url_type == 4) {
                    if (this.boardPage == '' || this.boardPage == undefined) {
                        this.$message.error('请选择应用内部页面');
                    } else if (this.srp.indexOf(this.boardPage) != -1) {
                        if (this.addlist.url_param == '') {
                            this.$message.error('请填写app页面参数');
                        } else {
                            a = this.boardPage + "?" + this.addlist.url_param
                            console.log(this.addlist.url_param)
                            form = {
                                most_show_count: this.addlist.most_show_count,
                                name: this.addlist.name,
                                board_id: this.addlist.board_id,
                                title: this.addlist.title,
                                sub_title: this.addlist.sub_title,
                                start_time: this.addlist.start_time,
                                end_time: this.addlist.end_time,
                                ordid: this.addlist.ordid,
                                status: this.addlist.status,
                                url_type: this.addlist.url_type,
                                url_param: a,
                                bg_color: this.addlist.bg_color,
                                font_color: this.addlist.font_color,
                                content: this.img_url[0],
                                selected_content: this.selected_content[0]
                            };

                        }
                    }else if (this.boardPage=='other') {
                        if (this.addlist.url_param == '') {
                            this.$message.error('请填写其他页面参数');
                        } else {
                            form = {
                                most_show_count: this.addlist.most_show_count,
                                name: this.addlist.name,
                                board_id: this.addlist.board_id,
                                title: this.addlist.title,
                                sub_title: this.addlist.sub_title,
                                start_time: this.addlist.start_time,
                                end_time: this.addlist.end_time,
                                ordid: this.addlist.ordid,
                                status: this.addlist.status,
                                url_type: this.addlist.url_type,
                                url_param: this.addlist.url_param,
                                bg_color: this.addlist.bg_color,
                                font_color: this.addlist.font_color,
                                content: this.img_url[0],
                                selected_content: this.selected_content[0]
                            };
                            let res = await adcreate(form);
                            if (res.code === 10000) {
                                this.$message.success("提交成功");
                                this.getProductListData();
                            } else {
                                this.$message.error(res.message);
                            }
                            this.isShowDetail = false;
                        }
                    } else {
                        this.addlist.url_param = ''
                        form = {
                            most_show_count: this.addlist.most_show_count,
                            name: this.addlist.name,
                            board_id: this.addlist.board_id,
                            title: this.addlist.title,
                            sub_title: this.addlist.sub_title,
                            start_time: this.addlist.start_time,
                            end_time: this.addlist.end_time,
                            ordid: this.addlist.ordid,
                            status: this.addlist.status,
                            url_type: this.addlist.url_type,
                            url_param: this.boardPage,
                            bg_color: this.addlist.bg_color,
                            font_color: this.addlist.font_color,
                            content: this.img_url[0],
                            selected_content: this.selected_content[0]

                        };
                        let res = await adcreate(form);
                        if (res.code === 10000) {
                            this.$message.success("提交成功");
                            this.getProductListData();
                        } else {
                            this.$message.error(res.message);
                        }
                        this.isShowDetail = false;

                    }
                } else if (this.addlist.url_type == 2 || this.addlist.url_type == 3) {
                    if (this.addlist.url_param == '') {
                        this.$message.error('请填写app页面参数');
                    } else {
                        form = {
                            most_show_count: this.addlist.most_show_count,
                            name: this.addlist.name,
                            board_id: this.addlist.board_id,
                            title: this.addlist.title,
                            sub_title: this.addlist.sub_title,
                            start_time: this.addlist.start_time,
                            end_time: this.addlist.end_time,
                            ordid: this.addlist.ordid,
                            status: this.addlist.status,
                            url_type: this.addlist.url_type,
                            url_param: this.addlist.url_param,
                            bg_color: this.addlist.bg_color,
                            font_color: this.addlist.font_color,
                            content: this.img_url[0],
                            selected_content: this.selected_content[0]

                        };
                        let res = await adcreate(form);
                        if (res.code === 10000) {
                            this.$message.success("提交成功");
                            this.getProductListData();
                        } else {
                            this.$message.error(res.message);
                        }
                        this.isShowDetail = false;

                    }
                }
                else {
                    form = {
                        most_show_count: this.addlist.most_show_count,
                        name: this.addlist.name,
                        board_id: this.addlist.board_id,
                        title: this.addlist.title,
                        sub_title: this.addlist.sub_title,
                        start_time: this.addlist.start_time,
                        end_time: this.addlist.end_time,
                        ordid: this.addlist.ordid,
                        status: this.addlist.status,
                        url_type: 0,
                        url_param: '',
                        bg_color: this.addlist.bg_color,
                        font_color: this.addlist.font_color,
                        content: this.img_url[0],
                        selected_content: this.selected_content[0]

                    };

                    let res = await adcreate(form);
                    if (res.code === 10000) {
                        this.$message.success("提交成功");
                        this.img_url = []
                        this.getProductListData();
                    } else {
                        this.$message.error(res.message);
                    }
                    this.isShowDetail = false;


                }


            },
            //修改广告
            async getEditUpdateData() {
                let a;
                let form;
                if (this.addlist.name == '' || this.addlist.name == undefined) {
                    this.$message.error('请输入广告名称');
                } else if (this.addlist.board_id == '' || this.addlist.board_id == undefined) {
                    this.$message.error('请选择广告位');
                } else if (this.addlist.title == '' || this.addlist.title == undefined) {
                    this.$message.error('请输入标题');
                } else if (this.addlist.sub_title == '' || this.addlist.sub_title == undefined) {
                    this.$message.error('请输入副标题');
                } else if (this.addlist.start_time == '' || this.addlist.start_time == undefined ||
                    this.addlist.end_time == '' || this.addlist.end_time == undefined) {
                    this.$message.error('请选择广告时间');
                } else if (this.img_url[0] == '' || this.img_url[0] == undefined) {
                    this.$message.error('请添加广告图片');
                } else if (this.addlist.url_type == 4) {
                    if (this.boardPage == '' || this.boardPage == undefined) {
                        this.$message.error('请选择应用内部页面');
                    } else if (this.srp.indexOf(this.boardPage) != -1) {
                        console.log(this.addlist.url_param)
                        if (this.addlist.url_param == '') {
                            this.$message.error('请填写app页面参数');
                        } else {
                            a = this.boardPage + "?" + this.addlist.url_param
                            console.log(this.addlist.url_param)
                            form = {
                                id: this.addlist.id,

                                most_show_count: this.addlist.most_show_count,
                                name: this.addlist.name,
                                board_id: this.addlist.board_id,
                                title: this.addlist.title,
                                sub_title: this.addlist.sub_title,
                                start_time: this.addlist.start_time,
                                end_time: this.addlist.end_time,
                                ordid: this.addlist.ordid,
                                status: this.addlist.status,
                                url_type: this.addlist.url_type,
                                url_param: a,
                                bg_color: this.addlist.bg_color,
                                font_color: this.addlist.font_color,
                                content: this.img_url[0],
                                selected_content: this.selected_content[0]
                            };
                            let res = await adupdate(form);
                            if (res.code === 10000) {
                                this.$message.success("提交成功");
                                this.getProductListData();
                            } else {
                                this.$message.error(res.message);
                            }

                            this.isShowUpdate = false;
                        }
                    }else if (this.boardPage=='other') {
                        if (this.addlist.url_param == '') {
                            this.$message.error('请填写其他页面参数');
                        } else {
                            form = {
                                id: this.addlist.id,
                                most_show_count: this.addlist.most_show_count,
                                name: this.addlist.name,
                                board_id: this.addlist.board_id,
                                title: this.addlist.title,
                                sub_title: this.addlist.sub_title,
                                start_time: this.addlist.start_time,
                                end_time: this.addlist.end_time,
                                ordid: this.addlist.ordid,
                                status: this.addlist.status,
                                url_type: this.addlist.url_type,
                                url_param: this.addlist.url_param,
                                bg_color: this.addlist.bg_color,
                                font_color: this.addlist.font_color,
                                content: this.img_url[0],
                                selected_content: this.selected_content[0]
                            };
                            let res = await adupdate(form);
                            if (res.code === 10000) {
                                this.$message.success("提交成功");
                                this.getProductListData();
                            } else {
                                this.$message.error(res.message);
                            }

                            this.isShowUpdate = false;
                        }
                    } else {
                        this.addlist.url_param = ''
                        form = {
                            id: this.addlist.id,
                            most_show_count: this.addlist.most_show_count,
                            name: this.addlist.name,
                            board_id: this.addlist.board_id,
                            title: this.addlist.title,
                            sub_title: this.addlist.sub_title,
                            start_time: this.addlist.start_time,
                            end_time: this.addlist.end_time,
                            ordid: this.addlist.ordid,
                            status: this.addlist.status,
                            url_type: this.addlist.url_type,
                            url_param: this.boardPage,
                            bg_color: this.addlist.bg_color,
                            font_color: this.addlist.font_color,
                            content: this.img_url[0],
                            selected_content: this.selected_content[0]

                        };
                        let res = await adupdate(form);
                        if (res.code === 10000) {
                            this.$message.success("提交成功");
                            this.getProductListData();
                        } else {
                            this.$message.error(res.message);
                        }

                        this.isShowUpdate = false;

                    }
                } else if (this.addlist.url_type == 2 || this.addlist.url_type == 3) {
                    if (this.addlist.url_param == '') {
                        this.$message.error('请填写app页面参数');
                    } else {
                        form = {
                            id: this.addlist.id,
                            most_show_count: this.addlist.most_show_count,
                            name: this.addlist.name,
                            board_id: this.addlist.board_id,
                            title: this.addlist.title,
                            sub_title: this.addlist.sub_title,
                            start_time: this.addlist.start_time,
                            end_time: this.addlist.end_time,
                            ordid: this.addlist.ordid,
                            status: this.addlist.status,
                            url_type: this.addlist.url_type,
                            url_param: this.addlist.url_param,
                            bg_color: this.addlist.bg_color,
                            font_color: this.addlist.font_color,
                            content: this.img_url[0],
                            selected_content: this.selected_content[0]

                        };
                        let res = await adupdate(form);
                        if (res.code === 10000) {
                            this.$message.success("提交成功");
                            this.getProductListData();
                        } else {
                            this.$message.error(res.message);
                        }

                        this.isShowUpdate = false;

                    }
                }
                else {
                    form = {
                        id: this.addlist.id,

                        most_show_count: this.addlist.most_show_count,
                        name: this.addlist.name,
                        board_id: this.addlist.board_id,
                        title: this.addlist.title,
                        sub_title: this.addlist.sub_title,
                        start_time: this.addlist.start_time,
                        end_time: this.addlist.end_time,
                        ordid: this.addlist.ordid,
                        status: this.addlist.status,
                        url_type: 0,
                        url_param: '',
                        bg_color: this.addlist.bg_color,
                        font_color: this.addlist.font_color,
                        content: this.img_url[0],
                        selected_content: this.selected_content[0]

                    };

                    let res = await adupdate(form);
                    if (res.code === 10000) {
                        this.$message.success("提交成功");
                        this.img_url = []
                        this.getProductListData();
                    } else {
                        this.$message.error(res.message);
                    }

                    this.isShowUpdate = false;

                }
            }
        }
    };
</script>

<style lang="scss" scoped>

    .shop {
        padding: 20px;
        position: relative;

        .search {
            float: right;
            .input {
                width: 200px;
            }
        }
        .shop_table_list {
            margin-top: 20px;
        }
        .shop_title {
            font-weight: 700;
        }

        .pagination {
            float: right;
        }
        .status—desc {
            display: inline;
            margin-left: 5px;
        }

        .img_main {
            color: #ffffff;
            background-color: #f4222d;
            width: 60px;
            text-align: center;
            position: absolute;
            top: 0;
            left: 10%;
            margin-left: 30px;
            // z-index: !important;
        }
        .shop_info_dalog {
            margin-top: 20px;
            padding: 0 20px;
        }
        .dialog-footer {
            margin: 20px 0;
            text-align: center;
        }
    }
</style>
<style>
    .advertisingManagement .el-input__inner {
        height: 30px !important;
    }
</style>
